<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="baseUrl" uri="/WEB-INF/tld/baseUrl.tld"%>
<!DOCTYPE HTML>
<html>
<head>
<title>文件上传</title>
<jsp:include page="/WEB-INF/views/layout/resources.jsp"></jsp:include>
</head>
<body>
	<div class="container-fluid">
		<div class="col-xs-6">
			<form id="uploadPackageForm" enctype="multipart/form-data" method="post">
				<div class="form-group">
					<label for="type">包类型</label> <select name="type" class="form-control">
						<option value="1">收音机</option>
						<option value="2">语言助手</option>
						<option value="3">行车记录仪</option>
						<option value="4">音乐</option>
						<option value="5">OBD App</option>
						<option value="6">AD Robot</option>
					</select>
				</div>
				<div class="form-group">
					<label for="version">版本号</label> <input type="text" class="form-control" name="version">
				</div>
				<div class="form-group">
					<label for="file">升级包</label> <input class="form-control" type="file" name="file">
				</div>
				<div class="form-group text-center">
					<button type="button" onclick="upload();" class="btn btn-default">提交</button>
				</div>

			</form>
		</div>
	</div>
</body>
<script type="text/javascript">
	function upload() {
		var index = layer.load(1, {
			shade : [ 0.1, '#fff' ],
			time : 100 * 1000
		});
		debugger
		$("#uploadPackageForm").ajaxSubmit({
			type : "POST",//提交类型  
			dataType : "json",//返回结果格式  
			url : createUrl("/ota/android/upload"),//请求地址  
			success : function(data) {//请求成功后的函数  
				if (data.success) {
					alert("上传升级包成功");
				} else {
					alert(data.error);
				}
				layer.close(index);
			},
			error : function(data) {
				alert(data);
				layer.close(index);
			},//请求失败的函数  
			async : true
		});
	}
</script>
</html>